require([
    "esri/identity/IdentityManager",
    "esri/Map",
    "esri/geometry/SpatialReference",
    "esri/layers/TileLayer",
    "esri/layers/FeatureLayer",
    "esri/layers/SceneLayer",
    "esri/layers/MapImageLayer",
    "esri/tasks/QueryTask",
    "esri/tasks/support/Query",
    "esri/Graphic",
    "esri/symbols/SimpleFillSymbol",
    "esri/PopupTemplate",
    "esri/Camera",
    "esri/widgets/Zoom",
    "esri/core/urlUtils",
    "utils/SHCTiledMapServiceLayer",
    "utils/SHCMapServiceLayer",

    
    "esri/views/SceneView",
    "esri/geometry/Extent",
    "dijit/form/RadioButton",
    "dijit/form/CheckBox",
    "dojo/ready"
], function (IdentityManager, Map, SpatialReference, TileLayer,FeatureLayer, SceneLayer, MapImageLayer,QueryTask,Query,Graphic,SimpleFillSymbol,PopupTemplate,Camera,Zoom, urlUtils,
    SHCTiledMapServiceLayer, SHCMapServiceLayer,
    
    SceneView, Extent, RadioButton, CheckBox, ready) {

    ready(function () {
        var selectMode = "singleMode";
        //token
        // MapImageLayer
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.open('GET', 'http://10.89.5.191/onemap/tokens/generateToken?request=getToken&username=cngzj&password=cngzj12345&clientid=ref.http://127.0.0.1:5500/&expiration=500', false);
        xmlhttp.send();

        var GLOBAL_TOKEN = xmlhttp.responseText;
        // var GLOBAL_TOKEN = 'K2QVznlkwejtRfAhWbzeWToz2sUCEXrUU9EZNCUQDsSCawSlpit-FcPGsF9kde7-pHdk08-5hUPOTh-tGA9fCv9mUrVzM0t_QrFHG4rQwd-HVc-7a9fY6-7Nt4AVak8iHgsfcNPkCTHO3fspffJE-MQih7EMXXFXGHHFCj3cGNLLX39KdePTz6M6Y8TPGK5e';

        IdentityManager.registerToken({
            server:"http://10.89.5.191/OneMapServer/rest/services",
            token:GLOBAL_TOKEN
        })

        IdentityManager.on("dialog-create", function () {
            IdentityManager.dialog.open = true;
        });
        //创建地图
        var map = new Map();
        map.ground.opacity = 0;
        var fullExtent = new Extent({
            "xmin": -65000,
            "ymin": -76000,
            "xmax": 75000,
            "ymax": 72000,
            "spatialReference": SpatialReference.WebMercator
        });

        // var mapAnSe = new SHCTiledMapServiceLayer({
        //     url: "http://10.89.5.191/OneMapServer/rest/services/shmw2_blueblack/MapServer",
        //     fullExtent: fullExtent,
        //     opacity: 1,
        //     token: GLOBAL_TOKEN
        // });

        
        //切片图层
        
        
        
        var zhengwuBase = new TileLayer("http://10.89.5.191/OneMapServer/rest/services/zwdt_base/MapServer");
        var zhengwuAnse =   new TileLayer("http://10.89.5.191/OneMapServer/rest/services/shmw2_blueblack/MapServer");
        var guihua = new TileLayer("http://10.89.5.191/OneMapServer/rest/services/DLGMap2021/MapServer");
        
       
        //动态图层
        // var fangchan = new MapImageLayer("http://10.89.5.191/OneMapServer/rest/services/cn_fdsj/MapServer");
        // var fangchan = new FeatureLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//HGQDKTX_20210226/MapServer/1");
        
        // var hongxian = new MapImageLayer("http://10.89.5.191/OneMapServer/rest/services/hxsj/MapServer");
        // // var jianshe = new MapImageLayer("http://10.89.5.191/OneMapServer/rest/services/cn_jsgc/MapServer");
        // var kongxiang = new MapImageLayer("http://10.89.5.191/OneMapServer/rest/services/cn_kxgh_ck/MapServer");
        // var changningQujie = new MapImageLayer("http://10.89.5.191/OneMapServer/rest/services/BOUNDARY/MapServer");

         // var jianshe = new FeatureLayer({
        //     url: "http://10.89.5.191/OneMapServer/rest/services/cn_jsgc/MapServer",
        //     title: "城市",
        //     outFields: ["OBJECTID", "ename"],
           
       
        //     popupTemplate: popupTemplate
        // });

        //结构树
        // var map11 = new FeatureLayer("http://10.89.5.191/OneMapServer/rest/services/cn_fdsj/MapServer/0");
        var map11 = new FeatureLayer({
                url:    "http://10.89.5.191/OneMapServer/rest/services/cn_kxgh_ck/MapServer/0",
                mode: FeatureLayer.MODE_ONDEMAND,
                dynamicDataSource: {
                    type: "data-layer",
                    dataSource: {
                        type: "table",
                        workspaceId: '0',
                        dataSourceName: '文件名'
                    }
                }
            });
        

        var map12 = new FeatureLayer("http://10.89.5.191/OneMapServer/rest/services/cn_fdsj/MapServer/1");
        var map21 = new FeatureLayer("http://10.89.5.191/OneMapServer/rest/services/hxsj/MapServer/0");
        var map22 = new FeatureLayer("http://10.89.5.191/OneMapServer/rest/services/hxsj/MapServer/1");
        var map31 = new FeatureLayer("http://10.89.5.191/OneMapServer/rest/services/cn_jsgc/MapServer/0");
        var map32 = new FeatureLayer("http://10.89.5.191/OneMapServer/rest/services/cn_jsgc/MapServer/1");
        var map41 = new FeatureLayer("http://10.89.5.191/OneMapServer/rest/services/cn_kxgh_ck/MapServer/0");
        var map42 = new FeatureLayer("http://10.89.5.191/OneMapServer/rest/services/cn_kxgh_ck/MapServer/1");
        var map43 = new FeatureLayer("http://10.89.5.191/OneMapServer/rest/services/cn_kxgh_ck/MapServer/2");
        var map44 = new FeatureLayer("http://10.89.5.191/OneMapServer/rest/services/cn_kxgh_ck/MapServer/3");

        
        
        // ***** 小爱给的图层  ****
        //var map44 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_cbxm_20210225/MapServer");
        var TD_hbjds_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services/TD_hbjds_20210225/MapServer");
        var TD_jsydpzs_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_jsydpzs_20210225/MapServer");
        var TD_nzy_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_nzy_20210225/MapServer");
        var  TD_syqdzd_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_syqdzd_20210225/MapServer");
        var TD_ttzyclip_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_ttzyclip_20210225/MapServer");
        var TD_tdgysp_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_tdgysp_20210225/MapServer");
        var TD_tdycsyht_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_tdycsyht_20210225/MapServer");
        var TD_zfxs_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_zfxs_20210225/MapServer");
        var TD_gdzy_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_gdzy_20210225/MapServer");
        var TD_syqxzd_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_syqxzd_20210225/MapServer");
        var TD_tdcb_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_tdcb_20210225/MapServer");
        var TD_tdjy_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_tdjy_20210225/MapServer");
        var TD_ychwfyd_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_ychwfyd_20210225/MapServer");
        var TD_ydys_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_ydys_20210225/MapServer");
        var  TD_zd_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//TD_zd_20210225/MapServer");

        var  GH_cykz_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//GH_cykz_20210225/MapServer");
        var  GH_cskf_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services/GH_cskf_20210225/MapServer");
        var  GH_dlhx_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services/GH_dlhx_20210225/MapServer");
        var  GH_hxdl_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//GH_hxdl_20210225/MapServer");
        var  GH_ggyq_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//GH_ggyq_20210225/MapServer");
        var  GH_hdzxx_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//GH_hdzxx_20210225/MapServer");
        var  GH_jsydclip_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//GH_jsydclip_20210225/MapServer");
        var  GH_kgdk_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//GH_kgdk_20210225/MapServer");
        var   GH_kgxm_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//GH_kgxm_20210225/MapServer");
        var  GH_sykjcxbjgh_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//GH_sykjcxbjgh_20210225/MapServer");
        var  GH_systwlgh_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//GH_systwlgh_20210225/MapServer");
        var  GH_syxjzzyfzkjgh_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//GH_syxjzzyfzkjgh_20210225/MapServer");
        var  GH_syydbjghclip_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//GH_syydbjghclip_20210225/MapServer");

        var  JS_gcghxkz_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//JS_gcghxkz_20210225/MapServer");
        var  JS_hdghtj_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//JS_hdghtj_20210225/MapServer");
        var  JS_sjfa_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//JS_sjfa_20210225/MapServer");
        var  JS_szgx_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//JS_szgx_20210225/MapServer");
        var  JS_szgcxkz_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//JS_szgcxkz_20210225/MapServer");
        var  JS_szjtclip_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//JS_szjtclip_20210225/MapServer");
        var  JS_szxzyjsclip_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//JS_szxzyjsclip_20210225/MapServer");
        var   JS_xzyjs_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//JS_xzyjs_20210225/MapServer");
        var   JS_ydghxkz_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//JS_ydghxkz_20210225/MapServer");
        var  JS_zzys_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//JS_zzys_20210225/MapServer");

        var  DK_xmcbcrhb_20210525 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//DK_xmcbcrhb_20210525/MapServer");
        var   DK_ycr_20210525 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//DK_ycr_20210525/MapServer");
        var  DK_yhb_20210525 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//DK_yhb_20210525/MapServer");
        var  DK_ycb_20210525 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//DK_ycb_20210525/MapServer");

        var  HGQ_hgqfw_20210225 =   new MapImageLayer("https://winwangwei.smisanwei.cn:6443/arcgis/rest/services//HGQ_hgqfw_20210225/MapServer");

        map.add(zhengwuBase);
        // map.add(layerBaiMo);
        //相机
        var cam = new Camera({
            heading: 359.54,
            tilt: 60.70,
            position: {
                latitude: 14740,
                longitude: -201776.29,
                z: 62642.08,
                spatialReference: {
                    wkid: 3857
                }
            }
        });
        var view = new SceneView({
            //  camera: cam,
            container: "viewDiv",
            map: map,
            viewingMode: "local",
            zoom:2
        });
        view.ui.remove('attribution');
        view.ui.remove('zoom');
        view.ui.move('compass', 'top-right');
        view.ui.empty('top-left');
        //-----------------------------------------------
        // var rdSingleMode = new RadioButton({
        //     checked: true,
        //     value: 'singleMode',
        //     name: 'selectMode',
        //     onChange: function (e) {
        //         if (e) {
        //             selectMode = "singleMode";
        //         } else {
        //             selectMode = "multipleMode";
        //         }
        //     }
        // }, 'rdSingleMode');
        // var rdMultipleMode = new RadioButton({
        //     checked: false,
        //     value: 'multipleMode',
        //     name: 'selectMode',
        //     // onChange:function(e){
        //     //     console.log("",e);
        //     // }
        // }, 'rdMultipleMode');
        // var cbMapAnSe = new CheckBox({ name: '', value: '', checked: true },'cbMapAnSe').startup();
        // $("#rdSingleMode").change(function () {
        //     selectMode = "singleMode";
        // });
        // $("#rdMultipleMode").change(function () {
        //     selectMode = "multipleMode";
        // });
        
        //事件 单选
        $(':radio[name=mapLayer]').each(function () {
            $(this).click(function () {
                if ($(this).is(':checked')) {
                    //选中某个项
                    $(':radio[name=mapLayer]').each(function () {
                        $(this).prop('checked', false);
                        map.remove(eval($(this).val()))
                    })
                    $(this).prop('checked', true);
                    map.add(eval($(this).val()),0);
                }
            })
        })
        
        //白模
        $('#layerBaiMo').change(function () {
            if ($(this).is(':checked')) {
                map.add(eval($(this).val()))
            } else {
                map.remove(eval($(this).val()))
            }
        })
        // $("input[name=mapLayer]").change(function(e){

        //     if(selectMode==="singleMode"){
        //         $('input[name=mapLayer]').each(function(){
        //             if($(this).is(':checked')){
        //                 map.add(eval($(this).val()))
        //             }else{
        //                 map.remove(eval($(this).val()))
        //             }
        //         })
        //     }else{
        //         $('input[name=mapLayer]').each(function(){
        //             if($(this).is(':checked')){
        //                 map.add(eval($(this).val()))
        //                 // console.log($(this).val());
        //             }else{
        //                 map.remove(eval($(this).val()))
        //             }
        //         })
        //     }
        // });
        
        //查询

        // 弹出气泡的模板
    var popupTemplate = new PopupTemplate({
        title: "城市详细信息",
        // content: "<table><tr><td>城市名称</td><td>{CITY_NAME}</td></tr>" +
        //     "<tr><td>人口数量</td><td>{POP}</td></tr></table>"
        content: [{
            type: "fields",
                fieldInfos: [{
                    fieldName: "OBJECTID",
                    label: "要素ID"
                }, {
                    fieldName: "ename",
                    label: "人口"
                }]
        }]
    });

    var templatehaiwu = {
        // autocasts as new PopupTemplate()
        title: "我是标题",
        content: [
            {
                type: "fields",
                fieldInfos: [
                    {
                        fieldName: "xmbh",
                        label: "项目编号"
                    },
                    {
                        fieldName: "dybh",
                        label: "单元编号"
                    },
                    {
                        fieldName: "dkbh",
                        label: "地块编号"
                    },
                    {
                        fieldName: "jfbh",
                        label: "街坊编号"
                    }
                    
                ]
            }
        ]
    };

    function getDatabaseMap(){
        
            $.ajax({
                //请求方式
                type : "GET",
                //请求的媒体类型
                contentType: "application/json;charset=UTF-8",
                //请求地址
                url : "http://localhost:8080/cnplan/getGis?x=-3529.5448559661445&y=-947.1008561364556&name=kxfm",
                //数据，json字符串
                // data : JSON.stringify(list),
                
                //请求成功
                success : function(result) {
                    console.log(result);
                },
                //请求失败，包含具体的错误信息
                error : function(e){
                    console.log(e.status);
                    console.log(e.responseText);
                }
            });
         
    } 

    view.on("click", function(event) {
        getDatabaseMap();


   
        let finalLayer = window.finalMapTool[window.finalMapTool.length - 1];
        if(finalLayer){
            var point = event.mapPoint;
            var x = point.x;
            var y = point.y;
            //数据库字段映射表 -> 取出表名
            let mapIndex = finalLayer.toString().substr(0,1);
            let layerIndex = finalLayer.toString().substr(1,2);
            let databaseStr = '';
            let mapIndexArray = [
                {index:1,name:'fdsj'},
                {index:2,name:'hxsj'},
                {index:3,name:'zxgh'},
                {index:4,name:'kxgh'}
            ]
            mapIndexArray.forEach((mapIndexItem,mapIndexIndex)=>{
                console.log(mapIndexItem,mapIndex);
                if(mapIndexItem.index == mapIndex){
                    databaseStr = mapIndexItem.name;
                }
            })
            console.log(databaseStr);
            //获取字段 -> 取出表结构
            var layersParams = window.layersParams[0];
           let layerArray = [];
            for(let index in layersParams){
                if(index == databaseStr){
                    layerArray = layersParams[index];
                }
            }
            let fieldInfosTmp = [];
            for(let layeri in layerArray){
                if(layeri == (layerIndex - 1)){
                    fieldInfosTmp = layerArray[layeri].fieldInfos;
                }
            }
            
            templatehaiwu.content[0].fieldInfos = fieldInfosTmp;
            console.log(templatehaiwu,'---',fieldInfosTmp);
            map11.popupTemplate = templatehaiwu;
        }
    })


        //底图切换
        $('.baseMapContainter').on('click',function(){
            console.log('bbb');
            if($('.baseMap_img').hasClass("animation_hiden")){
                $('.baseMap_img').removeClass("animation_hiden").addClass("animation_show")
                // console.log
                // $('.baseMap_img').data('mapAttr')
            }else if($('.baseMap_img').hasClass("animation_show")){
                $('.baseMap_img').removeClass("animation_show").addClass("animation_hiden")
            }
            
        })
        
        const mapConfig = [
            {
                map:'zhengwuBase',
                url:'base'
            },
            {
                map:'zhengwuAnse',
                url:'anse'
            },
            {
                map:'guihua',
                url:'guihua'
            }
        ];
        $(".baseMap_panl img").on('click',function(){
            var url = $(this)[0].src;
            $('.changeImage').attr('src',url);
            mapConfig.forEach((item,index)=>{
                if(url.includes(item.url)){
                    map.add(eval(item.map))
                    
                }else{
                    map.remove(eval(item.map))
                }
            })
            
        })
        window.finalMapTool = [];
        // 添加图层
        window.addMapLayers = function(params){
            params.forEach((item,index)=>{
                let name = 'map'+item;
                map.add(eval(name));
                window.finalMapTool.push(item);
            })    
            console.log(window.finalMapTool,'-----------')
        }

        //删除图层
        window.removeMapLayers = function(params){
            params.forEach((item,index)=>{
                let name = 'map'+item;
                map.remove(eval(name));
                window.finalMapTool.map((item1,index1)=>{
                    if(item1==item){
                        window.finalMapTool.splice(index1,1)
                    }
                })
                // window.finalMapTool=window.finalMapTool.filter((item1)=>{
                //     return item1!=item
                //     // if(item1 != item){
                //     //     delete(item1)
                //     // }
                // })

                // window.finalMapTool.forEach((item1,index1)=>{
                //     if(item1 == item){
                //         console.log(item1,item);
                //     }
                //     // if(item1 != item){
                //     //     delete(item1)
                //     // }
                // })
               
            })  
            console.log(window.finalMapTool,'===========');
        }
        // $(':checkbox[name=yaosuLayer]').each(function () {
        //     $(this).click(function () {
        //         console.log($(this).is(':checked'),'checkbox',$(this).val(),'---',eval($(this).val()));
        //         if ($(this).is(':checked')) {
        //             map.add(eval($(this).val()))
        //             // map.push(eval($(this).val()))
        //         } else {
        //             map.remove(eval($(this).val()))
        //         }
        //     })
        // })

        //侧边栏
        $(".aside-containter div").on('click',function(){
            let value = $(this).attr('title');
            switch (value){
                case '图层' :
                    if($('.mapLayer').hasClass("aside_hiden")){
                        $('.mapLayer').removeClass("aside_hiden").addClass("aside_show")
                        // console.log
                        // $('.baseMap_img').data('mapAttr')
                    }else if($('.mapLayer').hasClass("aside_show")){
                        $('.mapLayer').removeClass("aside_show").addClass("aside_hiden")
                        hideAllMapLayers();
                    }
                break;
                case '放大' :
                    var zoom = new Zoom({
                        view: view
                        });
                        zoom.zoomIn();
                break;
                case '缩小' :
                    var zoom = new Zoom({
                        view: view
                        });
                        zoom.zoomOut();
                break;
                case '搜索' :
                    console.log('图层搜错');
                break;
                case '图层查询' :
                    console.log('图层查询');
                break;
                case '测量' :
                    console.log('图层测量操作');
                break;
                case '定位' :
                    //  view.camera = cam
                    // // Transform
                    view.goTo({
                        heading: 359.54,
                        tilt: 0,
                        position: {
                            x: 2000,
                            y: 2000,
                            z: 160000,
                            spatialReference: {
                                wkid: 3857
                            }
                        }
                    })
                break;
                default:
                    console.log('什么都不做');
                break;
            }
           
        })
        // 图层搜索查询
        $("#mapLayerQuerybtn").on('click',function(){
            // var citiesLayerUrl = " ... "; // Represents the REST endpoint for a layer of cities.
            var queryTask = new QueryTask({
                url:"http://10.89.5.191/OneMapServer/rest/services/cn_kxgh_ck/MapServer/0"
            });

            //查询条件
            var query = new Query();
            query.returnGeometry = true;
            query.outFields = ["*"];
            query.where = "dkbh='001-07'";  
 
            queryTask.execute(query).then(function(results){
                let geometry = results.features[0].geometry;
                //去生成高亮图形
                queryGeometry(geometry);
                //去显示面板
                //console.log(results.features[0]);
                //去定位到当前位置
                locationNow();
               
            });
           
            
        })

        function queryGeometry(val){
            //颜色样式
            var symbol = {
                type: "simple-fill",  // autocasts as new SimpleFillSymbol()
                color: [ 81,255,255, 0.4 ],
                style: "solid",
                outline: {  // autocasts as new SimpleLineSymbol()
                  color: "white",
                  width: 1
                }
            };
            let geometry = val;
            var polylineAtt = {
                Name: "Keystone Pipeline",
                Owner: "TransCanada"
            };
            var polylineGraphic = new Graphic({
                geometry: geometry,
                symbol: symbol,
                attributes: polylineAtt
            });
              
            view.graphics.add(polylineGraphic);
            
            console.log('高亮图形加载完毕');
            // view.goto([-4082.95835768937 -1861.7787818436118]);
            
 
 
 
 
            var options = {
                speedFactor: 0.1, // animation is 10 times slower than default
                easing: "out-quint" // easing function to slow down when reaching the target
            };
            
            
            console.log('000');
        }
        //函数
        function hideAllMapLayers(){
            console.log('ttt');
            let layers = window.finalMapTool;
            layers.forEach((item,index)=>{
                let name = 'map'+item;
                map.remove(eval(name));
            })
            window.finalMapTool = [];
        }

        function locationNow(){
            view.goTo({
                heading: 359.54,
                tilt: 0,
                position: {
                    x: -3561.131999999,
                    y: -1106.606000001,
                    z: 300,
                    spatialReference: {
                        wkid: 3857
                    }
                }
            })
        }
    })

});

function _add(item){
    window.addMapLayers(item);
}
function _remove(item){
    window.removeMapLayers(item);
}

